package com.xbongbong.pro.knowledge.base.pojo;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * @author mingliang.cao
 */
@Getter
@Setter
@ToString
public class CataloguePojo {

    /**
     * 目录id,前端组件需要兼容，所以名称修改为value
     */
    private Long value;

    /**
     * 目录名称,前端组件需要兼容，所以名称修改为label
     */
    private String label;

    /**
     * 上级目录id
     */
    private Long parentId;


    /**
     * 组内排序
     */
    private Integer sort;

    /**
     * 可见范围,parentId=0的时候才会有
     **/
    private List<OptionalRangePojo> viewConfig;

    /**
     * 子目录
     */
    private List<CataloguePojo> nodes;

    public void addNode(CataloguePojo materialCataloguePojo) {
        if (Objects.isNull(this.nodes)) {
            this.nodes = new ArrayList<>();
        }
        this.nodes.add(materialCataloguePojo);
    }

    public CataloguePojo() {
    }

    public CataloguePojo(Long value, String label, Long parentId, Integer sort) {
        this.value = value;
        this.label = label;
        this.parentId = parentId;
        this.sort = sort;
    }
}
